package com.orange.notificationsummary.utils;

import java.util.Collection;
import java.util.Map;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;

public class VipUtils {
	private static final String	TAG	= "VipUtils";

	public static void startVipActivity(Context context, String contacts_id) {
		Intent i = new Intent();
		i.setClassName(Constants.PKG_VIPCONTACT,
				"com.orange.vipcontact.VIPContactActivity");
		Bundle bd = new Bundle();
		bd.putString("contactid", contacts_id);
		i.putExtras(bd);
		NtfcUtils.startActivity(context, i);
	}

	/**
	 * get VIP contact flag
	 * 
	 * @param contacts_id
	 * @return
	 */
	public static boolean isVip(Context context, String contacts_id) {
		boolean flag = false;
		try {
			Context otherAppContext = context.createPackageContext(
					Constants.PKG_VIPCONTACT, Context.CONTEXT_IGNORE_SECURITY);

			SharedPreferences sp = otherAppContext.getSharedPreferences(
					"vip_contact", Context.MODE_WORLD_READABLE);
			Map<String, ?> map = sp.getAll();
			Collection<?> values = map.values();
			flag = values.contains(contacts_id);
		} catch (NameNotFoundException e) {
			LogHelper.e(TAG, "isVip. ", e);
			return false;
		}
		return flag;
	}

}
